2020-2021 Sunseeker Telemetry and Lighting System
usci_a_spi.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // usci_a_spi.h - Driver for the USCI_A_SPI Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_USCI_A_SPI_H__
8 #define __MSP430WARE_USCI_A_SPI_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_USCI_Ax__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include "inc/hw_memmap.h"
26 //*****************************************************************************
27 //
29 //
30 //*****************************************************************************
31 typedef struct USCI_A_SPI_initMasterParam {
36  uint8_t selectClockSource;
38  uint32_t clockSourceFrequency;
40  uint32_t desiredSpiClock;
45  uint8_t msbFirst;
50  uint8_t clockPhase;
54  uint8_t clockPolarity;
55 } USCI_A_SPI_initMasterParam;
56 
57 //*****************************************************************************
58 //
61 //
62 //*****************************************************************************
63 typedef struct USCI_A_SPI_changeMasterClockParam {
65  uint32_t clockSourceFrequency;
67  uint32_t desiredSpiClock;
68 } USCI_A_SPI_changeMasterClockParam;
69 
70 
71 //*****************************************************************************
72 //
73 // The following are values that can be passed to the clockPhase parameter for
74 // functions: USCI_A_SPI_initSlave(), and
75 // USCI_A_SPI_changeClockPhasePolarity(); the param parameter for functions:
76 // USCI_A_SPI_initMaster().
77 //
78 //*****************************************************************************
79 #define USCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT 0x00
80 #define USCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT UCCKPH
81 
82 //*****************************************************************************
83 //
84 // The following are values that can be passed to the msbFirst parameter for
85 // functions: USCI_A_SPI_initSlave(); the param parameter for functions:
86 // USCI_A_SPI_initMaster().
87 //
88 //*****************************************************************************
89 #define USCI_A_SPI_MSB_FIRST UCMSB
90 #define USCI_A_SPI_LSB_FIRST 0x00
91 
92 //*****************************************************************************
93 //
94 // The following are values that can be passed to the param parameter for
95 // functions: USCI_A_SPI_initMaster(); the clockPolarity parameter for
96 // functions: USCI_A_SPI_initSlave(), and
97 // USCI_A_SPI_changeClockPhasePolarity().
98 //
99 //*****************************************************************************
100 #define USCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH UCCKPL
101 #define USCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW 0x00
102 
103 //*****************************************************************************
104 //
105 // The following are values that can be passed to the param parameter for
106 // functions: USCI_A_SPI_initMaster().
107 //
108 //*****************************************************************************
109 #define USCI_A_SPI_CLOCKSOURCE_ACLK UCSSEL__ACLK
110 #define USCI_A_SPI_CLOCKSOURCE_SMCLK UCSSEL__SMCLK
111 
112 //*****************************************************************************
113 //
114 // The following are values that can be passed to the mask parameter for
115 // functions: USCI_A_SPI_enableInterrupt(), USCI_A_SPI_disableInterrupt(),
116 // USCI_A_SPI_getInterruptStatus(), and USCI_A_SPI_clearInterrupt() as well as
117 // returned by the USCI_A_SPI_getInterruptStatus() function.
118 //
119 //*****************************************************************************
120 #define USCI_A_SPI_TRANSMIT_INTERRUPT UCTXIE
121 #define USCI_A_SPI_RECEIVE_INTERRUPT UCRXIE
122 
123 //*****************************************************************************
124 //
125 // The following are values that can be passed toThe following are values that
126 // can be returned by the USCI_A_SPI_isBusy() function.
127 //
128 //*****************************************************************************
129 #define USCI_A_SPI_BUSY UCBUSY
130 #define USCI_A_SPI_NOT_BUSY 0x00
131 
132 //*****************************************************************************
133 //
134 // Prototypes for the APIs.
135 //
136 //*****************************************************************************
137 
138 //*****************************************************************************
139 //
153 //
154 //*****************************************************************************
155 extern bool USCI_A_SPI_initMaster(uint16_t baseAddress,
156  USCI_A_SPI_initMasterParam *param);
157 
158 //*****************************************************************************
159 //
169 //
170 //*****************************************************************************
171 extern void USCI_A_SPI_changeMasterClock(uint16_t baseAddress,
172  USCI_A_SPI_changeMasterClockParam *param);
173 
174 //*****************************************************************************
175 //
202 //
203 //*****************************************************************************
204 extern bool USCI_A_SPI_initSlave(uint16_t baseAddress,
205  uint8_t msbFirst,
206  uint8_t clockPhase,
207  uint8_t clockPolarity);
208 
209 //*****************************************************************************
210 //
228 //
229 //*****************************************************************************
230 extern void USCI_A_SPI_changeClockPhasePolarity(uint16_t baseAddress,
231  uint8_t clockPhase,
232  uint8_t clockPolarity);
233 
234 //*****************************************************************************
235 //
245 //
246 //*****************************************************************************
247 extern void USCI_A_SPI_transmitData(uint16_t baseAddress,
248  uint8_t transmitData);
249 
250 //*****************************************************************************
251 //
260 //
261 //*****************************************************************************
262 extern uint8_t USCI_A_SPI_receiveData(uint16_t baseAddress);
263 
264 //*****************************************************************************
265 //
281 //
282 //*****************************************************************************
283 extern void USCI_A_SPI_enableInterrupt(uint16_t baseAddress,
284  uint8_t mask);
285 
286 //*****************************************************************************
287 //
303 //
304 //*****************************************************************************
305 extern void USCI_A_SPI_disableInterrupt(uint16_t baseAddress,
306  uint8_t mask);
307 
308 //*****************************************************************************
309 //
326 //
327 //*****************************************************************************
328 extern uint8_t USCI_A_SPI_getInterruptStatus(uint16_t baseAddress,
329  uint8_t mask);
330 
331 //*****************************************************************************
332 //
344 //
345 //*****************************************************************************
346 extern void USCI_A_SPI_clearInterrupt(uint16_t baseAddress,
347  uint8_t mask);
348 
349 //*****************************************************************************
350 //
360 //
361 //*****************************************************************************
362 extern void USCI_A_SPI_enable(uint16_t baseAddress);
363 
364 //*****************************************************************************
365 //
375 //
376 //*****************************************************************************
377 extern void USCI_A_SPI_disable(uint16_t baseAddress);
378 
379 //*****************************************************************************
380 //
389 //
390 //*****************************************************************************
391 extern uint32_t USCI_A_SPI_getReceiveBufferAddressForDMA(uint16_t baseAddress);
392 
393 //*****************************************************************************
394 //
403 //
404 //*****************************************************************************
405 extern uint32_t USCI_A_SPI_getTransmitBufferAddressForDMA(uint16_t baseAddress);
406 
407 //*****************************************************************************
408 //
422 //
423 //*****************************************************************************
424 extern uint8_t USCI_A_SPI_isBusy(uint16_t baseAddress);
425 
426 //*****************************************************************************
427 //
428 // Mark the end of the C bindings section for C++ compilers.
429 //
430 //*****************************************************************************
431 #ifdef __cplusplus
432 }
433 #endif
434 
435 #endif
436 #endif // __MSP430WARE_USCI_A_SPI_H__
uint8_t transmitData
MPU_initThreeSegmentsParam param